
export const result = (response, authShowErrorMsg = true) => {
  const { data } = response
  if (data.code === 400 && authShowErrorMsg) {
    // message.error(data.msg)
	uni.showModal({
		title: '提示',
		content: `${data.msg}`,
		success: function (res) {
			if (res.confirm) {
				console.log('用户点击确定');
			} else if (res.cancel) {
				console.log('用户点击取消');
			}
		}
	});
  }
  // if (data.code === 200) {
  //   message.success(data.msg)
  // }
  return {
    success(cb) {
      if (data.code !== 400) {
        cb(data, response)
      }
      return this
    },
    fail(cb) {
      if (data.code === 400) {
        cb(data, response)
      }
      return this
    },
    finally(cb) {
      cb(data, response)
      return this
    },
  }
}

export const formatTimeStamp = (ts) => {
  const date = new Date(Number(ts))

  const YYYY = date.getFullYear()
  const MM = tsPadStart(date.getMonth() + 1)
  const DD = tsPadStart(date.getDate())

  const hh = tsPadStart(date.getHours())
  const mm = tsPadStart(date.getMinutes())
  const ss = tsPadStart(date.getSeconds())

  return `${YYYY}-${MM}-${DD} ${hh}:${mm}:${ss}`
}
